package com.lenovo.dh.voteclient;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;

import com.lenovo.dh.voteclient.utils.Utils;

public class LoginFragment extends Fragment{

	EditText editText;
	Button loginButton;
	ImageView logo;
	Handler handler =new Handler();
	public LoginFragment() {
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}
	
	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
	}
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.login_main, container, false);
		editText = (EditText) rootView.findViewById(R.id.nameEditText);
		loginButton = (Button) rootView.findViewById(R.id.login);
		logo = (ImageView) rootView.findViewById(R.id.logo);
		loginButton.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Utils.saveNameByShare(getActivity(),editText.getText().toString());
				getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.container, new PlaceholderFragmentEx()).commit();
			}
		});
		return rootView;
	}
	
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
	}

}